package com.bridgeQQ.client.control.commands
{
	import com.bridgeQQ.client.core.ICommand;
	import com.bridgeQQ.client.model.BridgeModel;
	
	import mx.collections.ArrayCollection;

	public class DelFriendTypeCommand extends BaseWrapper implements ICommand
	{
		public function DelFriendTypeCommand(respond:BaseRespond)
		{
			super(respond);
		}
		
		protected override function result(info:Object):void
		{
			var result:Object = info.respond.value;
			if(result == null || !result.result)
			{
				fault(info);
				return;
			}
			var ft:Object = info.item;
			var friends:ArrayCollection = ft.friends as ArrayCollection;
			var types:ArrayCollection = BridgeModel.instance.possess.friendTypes;
			types.removeItemAt(types.getItemIndex(info.item));		
			var length:int = types.length;
			if(friends.length <= 0)
			{
				return;
			}
			for (var i:int = 0; i < length; i++)
			{
				var type:Object = types.getItemAt(i);
				if(type.name == "normal")
				{
					type.friends.source = type.friends.source.concat(friends.source.concat);
					break;
				}
			}
		}
		
		protected override function fault(info:Object):void
		{
			
		}
		
	}
}